Title: All Tags
---
<div class="row">
    <div class="8u 12u$(medium)">
        @Html.Partial("_PostList", Model.DocumentList(Keys.PageDocuments).OrderByDescending(x => x.Get<DateTime>(BlogKeys.Published)))

        <nav>
            @{
                string tag = Model.String(BlogKeys.Tag).ToLowerInvariant().Replace(' ', '-');
                tag = tag.StartsWith(".") ? tag.Substring(1) : tag;
            }
            <ul class="pager">
                <li class="previous">            
                    @if(Model.Bool(Keys.HasPreviousPage))
                    {
                        <a href="@(Context.GetLink(Model.Document(Keys.PreviousPage)))"><span aria-hidden="true">&larr;</span> Newer</a>
                    }                
                </li>
                <li class="next">
                    @if(Model.Bool(Keys.HasNextPage))
                    {
                        <a href="@(Context.GetLink(Model.Document(Keys.NextPage)))">Older <span aria-hidden="true">&rarr;</span></a>
                    }
                </li>
            </ul>
        </nav>
    </div>
    
    <div class="4u 12u$(medium)">
        <ul class="actions small">
            @foreach (IDocument tagDocument in Documents[Blog.Tags]
                                                .GroupBy(x => x.String(BlogKeys.Tag)).Select(x => x.Where(p => p.Get<int>(Keys.CurrentPage) == 1).First())
                                                .OrderByDescending(x => x.Get<int>(Keys.TotalItems)))
            {
                string tagName = tagDocument.String(BlogKeys.Tag);
                string postCount = tagDocument.String(Keys.TotalItems);
                string buttonStyle = tagName == Model.String(BlogKeys.Tag) ? "special" : string.Empty;
                <li><a role="button" href="@Context.GetLink(tagDocument)" class="button small @buttonStyle">@tagName (@postCount)</a></li>
            }
        </ul>
    </div>
</div>